
// 框架的入口

const {VM} = require("vm2");
const fs = require("fs");

let FgBA = 0
const vm = new VM({
    sandbox: {
        h_log: console.log,
        setTimeout:setTimeout,
        setInterval:setTimeout,
        btoa:btoa,
        clearInterval:clearInterval,
        FgBA: FgBA,
    }
});
let code = "debugger;" // 便于调试
// 加载框架代码
code += fs.readFileSync("./env/init.js", "utf-8")
code += fs.readFileSync("./env/public/eventTarget.js", "utf-8")


code += fs.readFileSync("./env/dom/dom.js", "utf-8")
code += fs.readFileSync("./env/dom/tag.js", "utf-8")
code += fs.readFileSync("./env/dom/document.js", "utf-8")

code += fs.readFileSync("./env/bom/location.js", "utf-8")
code += fs.readFileSync("./env/bom/navigator.js", "utf-8")
code += fs.readFileSync("./env/bom/navigation.js", "utf-8")
code += fs.readFileSync("./env/bom/history.js", "utf-8")
code += fs.readFileSync("./env/bom/XMLHttpRequest.js", "utf-8")
code += fs.readFileSync("./env/bom/window.js", "utf-8")

code = `(function(){${code}})();`
code += fs.readFileSync("./work/work.js", "utf-8")

// 可留可不留
code = `try{${code};debugger}catch(e){h_log(e);debugger;};`

code+= `get_m()`
console.log(vm.run(code));
